package cn.ytr.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

/**
 * 实体类 客户跟进历史
 */
@Getter
@Setter
public class CustomerTraceHistory extends BaseDomain{

    //跟进状态- 潜在客户跟进
    public static final int TYPE_COMMON = 0;
    //跟进状态- 正式客户跟进
    public static final int TYPE_NORMAL = 1;

    //id
    private Long id;

    //跟进时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;

    //跟进记录
    private String traceDetails;

    //跟进方式-交流方式
    private SystemDictionaryItem traceType;

    //跟进结果
    private Integer traceResult;

    //备注
    private String remark;

    //跟进的客户
    private Customer customer;

    //录入的员工
    private Employee inputUser;

    //录入时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;

    //跟进类型
    private Integer type;

    //跟进结果的显示
    public String getDisplayTraceResult() {
        String temp = "中";
        switch (traceResult) {
            case 3: //3
                temp = "优";
                break;
            case 2:   //2
                temp = "中";
                break;
            case 1: //1
                temp = "差";
                break;
        }
        return temp;
    }

    //跟进的客户的状态类型的显示
    public String getDisplayType() {
        String temp = "潜在客户";
        switch (type) {
            case 0: //0
                temp = "潜在客户";
                break;
            case 1:   //1
                temp = "正式客户";
        }
        return temp;
    }

    //用来返回 json 数据的
    public String getJsonString() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("customerId", customer.getId());
        map.put("customerName", customer.getName());
        map.put("traceTime", traceTime);
        map.put("traceDetails", traceDetails);
        map.put("traceTypeId", traceType.getId());
        map.put("traceResult", traceResult);
        map.put("remark", remark);
        map.put("type", type);
        return JSON.toJSONString(map);
    }

}










































